package com.wuan.study.listener;

import com.wuan.study.event.Event_2;
import com.wuan.study.event.Event_3;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author v-wuan
 * @date 2023/7/13 16:18:17
 * @desc
 */
@Component
public class Listener2 {

    @EventListener(Event_2.class)
    public void creatEvent_2(Event_2 event) {
        System.out.println("注解监听器：" + event.getMsg());
    }


    @EventListener(Event_3.class)
    @Async//涉及多个数据库操作，考虑异步执行
    public void creatEvent_2(Event_3 event) {
        /*
        TODO:具体的业务逻辑,涉及数据库操作
            Long id = event.getId();
            xxService.removeById(id);
         */
        System.out.println("编号："+event.getId()+",删除成功！！！");
        /*
        TODO:具体的业务逻辑,涉及数据库操作
            yyService.updateByConfid(id);
         */
        System.out.println("编号："+event.getId()+",更新成功！！！");
    }
}
